package com.hup.utils.io.batch;

import java.util.ArrayList;

/**
 * 执行命令后,返回的字符串内容不是[解析器]预料中的内容时,抛出的异常
 *
 * @author hugan
 * @date 2020/1/22
 */
public class ErrRespException extends RuntimeException {

    public final String cmd;

    public ErrRespException(String cmd, String msg) {
        super(msg);
        this.cmd = cmd;
    }

    public static void doAssert(boolean isTrue, BaseBatch baseBatch, ArrayList<String> lstResp) {
        if (!isTrue) {
            throw new ErrRespException(baseBatch.cmd(), baseBatch.getErrMsg(lstResp));
        }
    }

    public static void doAssert(boolean isTrue, String cmd, String resp, BaseBatch baseBatch) {
        if (!isTrue) {
            throw new ErrRespException(cmd, baseBatch.getErrMsg(resp));
        }
    }

}
